<%@ page import="com.actimind.actitime.beans.UserBean,
                 com.actimind.actitime.Keys"%><%@ page errorPage="/error.jsp" %>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Projects</title>

    <script language="JavaScript" src="../js/at.js"></script>

    <link rel="stylesheet" href="../css/at.css" type="text/css">
</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="project" />
    <jsp:param name="pageAction" value="projectlist" />
</jsp:include>

<html:form scope="session" action="/project/projectlist.do" method="post" >

<input type="hidden" name="submitted" value="1" />

<bean:define id="form" name="ProjectListForm" scope="session" type="com.actimind.actitime.project.ProjectListForm" />

<table cellspacing="0" cellpadding="5" align="center" valign="top" border="0" bgcolor="#ffffff" width="770">
<tr>
    <td class="pagetitle">
        &nbsp;Projects
    </td>
    <td align="right">
        <input type="button" value="Add New Project" onclick="javascript:document.location.href='<html:rewrite href='projectadd.do'/>'" />
    </td>
</tr>
<tr>
    <td colspan="2">
        <table cellspacing="0" cellpadding="10" align="center" valign="top" border="0" width="100%">
        <tr>
            <td nowrap="1" class="formbuttonpane" style="text-align:left; vertical-align:middle">
                <span class="text">
                Customer:
                &nbsp;&nbsp;&nbsp;
                <at:select property="selectedCustomerId" maxlength="50">
                    <at:option value="0">-- All customers --</at:option>
                    <at:options collection="<%=Keys.CUSTOMERS_LIST_KEY%>" property="id" labelProperty="name" />
                </at:select>
                &nbsp;&nbsp;&nbsp;
                <html:submit value="Show Projects" />
                </span>
            </td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td colspan="2" class="pagetitle">
        <at:messages id="message" message="true">
            <span class="successmsg"><bean:write name="message"/></span>
        </at:messages>
        <at:errors />
    </td>
</tr>
<tr>
    <td colspan="2" class="text" wrap="1">
    &nbsp;<b>Filter criteria:</b>&nbsp;
    customer:&nbsp;<bean:write name="form" property="selectedCustomerName"/>
    </td>
</tr>
<tr>
    <td colspan="2">
        <table border="0" cellspacing="1" cellpadding="5"  align="center" width="770">
        <tr>
            <th class="listtblcolheader">Customer</th>
            <th class="listtblcolheader">Project</th>
            <th class="listtblcolheader" width="13%">Billing Status</th>
            <th class="listtblcolheader" width="18%">Project Description</th>
        </tr>

        <logic:equal name="form" property="projectsList.empty" value="true">
        <tr>
            <td class="listtblcell" colspan="4" align="center"><br />There are no projects registered for the selected customer.<br />&nbsp;</td>
        </tr>
        </logic:equal>

        <logic:iterate id="curProject" name="form" property="projectsList" type="com.actimind.actitime.beans.ProjectBean">
        <bean:define id="curProjectCustomer" name="curProject" property="customer" type="com.actimind.actitime.beans.CustomerBean" />

        <tr>
            <td class="listtblcell" align="center"><bean:write name="curProjectCustomer" property="name" /></td>
            <td class="listtblcell"><html:link href='<%="projectedit.do?projectId=" + curProject.getId()%>'><bean:write name="curProject" property="name" /></html:link></td>
            <logic:equal name="curProject" property="billable" value="true">
            <td align="center" class="listtblcell">Billable</td>
            </logic:equal>
            <logic:equal name="curProject" property="billable" value="false">
            <td align="center" class="listtblcell">Non-Billable</td>
            </logic:equal>
            <logic:notEmpty name="curProject" property="description" >
            <td align="center" class="listtblcell"><a href="javascript:popup('<html:rewrite href='<%="projectdetails.do?projectId=" + curProject.getId()%>'/>', 'popup', 758, 248, false, false, false);"><img src="../img/note.gif" width="14" height="16" border="0" hspace="0" vspace="0"></a></td>
            </logic:notEmpty>
            <logic:empty name="curProject" property="description" >
            <td align="center" class="listtblcell"><img src="../img/note_empty.gif" width="14" height="16" hspace="0" vspace="0"></td>
            </logic:empty>
        </tr>

        </logic:iterate>

        </table>
    </td>
</tr>
</table>

</html:form>

</body>
</html>
